#!/bin/sh
#
# generic-ftp	Start generic-ftp daemon
#
# chkconfig: 2345 08 92
# description:	Starts, stops and reloads generic-ftp daemon
#

# Source function library.
. /etc/init.d/functions

start() {

	echo -n "Stopping generic_ftp_daemon: "
	nohup /opt/generic-ftp/bin/generic_ftp_daemon.php >> /opt/generic-ftp/log/daemon.log 2>&1 &
	if [ $? -eq 0 ]; then
		success; echo
	else
		failure; echo; return 1
	fi
}

stop() {
	echo -n "Stopping generic_ftp_daemon: "
	pkill -f generic_ftp_daemon.php
	success; echo
}

reload() {
	echo -n "Stopping generic_ftp_daemon: "
	pkill -HUP -f generic_ftp_daemon.php
	success; echo
}

doqueue() {
	echo -n "Stopping generic_ftp_daemon: "
	pkill -USR1 -f generic_ftp_daemon.php
	success; echo
}

case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    reload)
	reload
	;;
    doqueue)
	doqueue
	;;
    *)
	echo $"Usage: $0 {start|stop|reload|doqueue}"
	exit 1
	;;
esac

exit 0
